﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x02000420 RID: 1056
public class DynamicBoneReferenceCtrl
{
	// Token: 0x06001A2E RID: 6702 RVA: 0x000E27D8 File Offset: 0x000E09D8
	public virtual bool Init(global::CharFemale _female)
	{
		this.chaFemale = _female;
		if (this.chaFemale == null)
		{
			return false;
		}
		global::DynamicBone_Ver02[] array = new global::DynamicBone_Ver02[]
		{
			this.chaFemale.getDynamicBone(global::CharFemaleBody.DynamicBoneKind.BreastL),
			this.chaFemale.getDynamicBone(global::CharFemaleBody.DynamicBoneKind.BreastR)
		};
		for (int i = 0; i < 2; i++)
		{
			this.lstsRef[i] = new List<global::DynamicBoneReferenceCtrl.Reference>();
			this.bonePtns[i] = new global::DynamicBone_Ver02.BonePtn();
			this.lstsTrans[i] = new List<Transform>();
			if (array[i] != null && array[i].Patterns.Count > 0)
			{
				this.bonePtns[i] = array[i].Patterns[0];
				for (int j = 1; j < this.bonePtns[i].Params.Count; j++)
				{
					this.lstsTrans[i].Add(this.bonePtns[i].Params[j].RefTransform);
				}
			}
		}
		return true;
	}

	// Token: 0x06001A2F RID: 6703 RVA: 0x000E28E0 File Offset: 0x000E0AE0
	public virtual bool Load(string _assetpath, string _file)
	{
		List<bool>[] array = new List<bool>[2];
		List<bool>[] array2 = new List<bool>[2];
		this.isInit = false;
		for (int i = 0; i < 2; i++)
		{
			this.InitDynamicBoneReferenceBone(this.bonePtns[i], this.lstsTrans[i]);
			if (this.lstsRef[i] != null)
			{
				this.lstsRef[i].Clear();
			}
			array[i] = new List<bool>();
			array[i].Add(false);
			array2[i] = new List<bool>();
			array2[i].Add(false);
		}
		if (_file == string.Empty)
		{
			return false;
		}
		TextAsset textAsset = global::GlobalMethod.LoadAllFolderInOneFile<TextAsset>(_assetpath, _file, null);
		if (textAsset == null || textAsset.text == string.Empty)
		{
			return false;
		}
		string[,] array3;
		global::GlobalMethod.GetListString(textAsset.text, out array3);
		int length = array3.GetLength(0);
		for (int j = 0; j < length; j += 4)
		{
			for (int k = 0; k < 4; k++)
			{
				global::DynamicBoneReferenceCtrl.Reference reference = new global::DynamicBoneReferenceCtrl.Reference();
				int num = j + k;
				int num2 = 0;
				reference.position.sizeS = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.position.sizeM = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.position.sizeL = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.rotation.sizeS = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.rotation.sizeM = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.rotation.sizeL = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.scale.sizeS = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.scale.sizeM = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				reference.scale.sizeL = new Vector3(float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]), float.Parse(array3[num, num2++]));
				int num3 = j / 4;
				array[num3].Add(array3[num, num2++] == "1");
				array2[num3].Add(array3[num, num2++] == "1");
				this.lstsRef[num3].Add(reference);
			}
		}
		for (int l = 0; l < 2; l++)
		{
			this.SetDynamicBoneRotationCalc(this.bonePtns[l], array[l]);
			this.SetDynamicBoneMoveLimitFlag(this.bonePtns[l], array2[l]);
		}
		this.isInit = true;
		return true;
	}

	// Token: 0x06001A30 RID: 6704 RVA: 0x000E2D6C File Offset: 0x000E0F6C
	public virtual bool Proc()
	{
		if (!this.isInit)
		{
			return false;
		}
		float shapeBodyValue = this.chaFemale.chaCustom.GetShapeBodyValue(1);
		for (int i = 0; i < 2; i++)
		{
			if (this.lstsTrans[i].Count == this.lstsRef[i].Count)
			{
				for (int j = 0; j < this.lstsRef[i].Count; j++)
				{
					if (!(this.lstsTrans[i][j] == null))
					{
						this.lstsTrans[i][j].localPosition = this.lstsRef[i][j].position.Calc(shapeBodyValue);
						this.lstsTrans[i][j].localRotation = Quaternion.Euler(this.lstsRef[i][j].rotation.Calc(shapeBodyValue));
						this.lstsTrans[i][j].localScale = this.lstsRef[i][j].scale.Calc(shapeBodyValue);
					}
				}
			}
		}
		return true;
	}

	// Token: 0x06001A31 RID: 6705 RVA: 0x000E2E94 File Offset: 0x000E1094
	public virtual bool InitDynamicBoneReferenceBone()
	{
		if (!this.isInit)
		{
			return false;
		}
		for (int i = 0; i < 2; i++)
		{
			this.InitDynamicBoneReferenceBone(this.bonePtns[i], this.lstsTrans[i]);
		}
		return true;
	}

	// Token: 0x06001A32 RID: 6706 RVA: 0x000E2ED8 File Offset: 0x000E10D8
	public virtual bool InitDynamicBoneReferenceBone(global::DynamicBone_Ver02.BonePtn _ptn, List<Transform> _lstTrans)
	{
		if (_ptn == null || _lstTrans == null)
		{
			return false;
		}
		List<bool> lstBool = new List<bool>
		{
			false,
			true,
			false,
			true,
			false
		};
		this.SetDynamicBoneRotationCalc(_ptn, lstBool);
		List<bool> lstBool2 = new List<bool>
		{
			false,
			false,
			false,
			false,
			false
		};
		this.SetDynamicBoneMoveLimitFlag(_ptn, lstBool2);
		foreach (Transform transform in _lstTrans)
		{
			if (!(transform == null))
			{
				transform.localPosition = Vector3.zero;
				transform.localRotation = Quaternion.identity;
				transform.localScale = Vector3.one;
			}
		}
		return true;
	}

	// Token: 0x06001A33 RID: 6707 RVA: 0x000E2FE0 File Offset: 0x000E11E0
	public virtual bool SetDynamicBoneRotationCalc(global::DynamicBone_Ver02.BonePtn _ptn, List<bool> _lstBool)
	{
		if (_ptn == null || _lstBool == null)
		{
			return false;
		}
		if (_lstBool.Count != _ptn.Params.Count)
		{
			return false;
		}
		for (int i = 0; i < _ptn.Params.Count; i++)
		{
			_ptn.Params[i].IsRotationCalc = _lstBool[i];
		}
		int num = 0;
		while (num < _ptn.ParticlePtns.Count && num < _lstBool.Count)
		{
			_ptn.ParticlePtns[num].IsRotationCalc = _lstBool[num];
			num++;
		}
		return true;
	}

	// Token: 0x06001A34 RID: 6708 RVA: 0x000E3088 File Offset: 0x000E1288
	public virtual bool SetDynamicBoneMoveLimitFlag(global::DynamicBone_Ver02.BonePtn _ptn, List<bool> _lstBool)
	{
		if (_ptn == null || _lstBool == null)
		{
			return false;
		}
		if (_lstBool.Count != _ptn.Params.Count)
		{
			return false;
		}
		for (int i = 0; i < _ptn.Params.Count; i++)
		{
			_ptn.Params[i].IsMoveLimit = _lstBool[i];
		}
		int num = 0;
		while (num < _ptn.ParticlePtns.Count && num < _lstBool.Count)
		{
			_ptn.ParticlePtns[num].IsMoveLimit = _lstBool[num];
			num++;
		}
		return true;
	}

	// Token: 0x04002122 RID: 8482
	protected bool isInit;

	// Token: 0x04002123 RID: 8483
	protected global::CharFemale chaFemale;

	// Token: 0x04002124 RID: 8484
	protected global::DynamicBone_Ver02.BonePtn[] bonePtns = new global::DynamicBone_Ver02.BonePtn[2];

	// Token: 0x04002125 RID: 8485
	protected List<Transform>[] lstsTrans = new List<Transform>[2];

	// Token: 0x04002126 RID: 8486
	protected List<global::DynamicBoneReferenceCtrl.Reference>[] lstsRef = new List<global::DynamicBoneReferenceCtrl.Reference>[2];

	// Token: 0x02000421 RID: 1057
	public class RateInfo
	{
		// Token: 0x06001A36 RID: 6710 RVA: 0x000E3138 File Offset: 0x000E1338
		public virtual Vector3 Calc(float _rate)
		{
			return (_rate < 0.5f) ? Vector3.Lerp(this.sizeS, this.sizeM, Mathf.InverseLerp(0f, 0.5f, _rate)) : Vector3.Lerp(this.sizeM, this.sizeL, Mathf.InverseLerp(0.5f, 1f, _rate));
		}

		// Token: 0x04002127 RID: 8487
		public Vector3 sizeS;

		// Token: 0x04002128 RID: 8488
		public Vector3 sizeM;

		// Token: 0x04002129 RID: 8489
		public Vector3 sizeL;
	}

	// Token: 0x02000422 RID: 1058
	public class Reference
	{
		// Token: 0x0400212A RID: 8490
		public global::DynamicBoneReferenceCtrl.RateInfo position = new global::DynamicBoneReferenceCtrl.RateInfo();

		// Token: 0x0400212B RID: 8491
		public global::DynamicBoneReferenceCtrl.RateInfo rotation = new global::DynamicBoneReferenceCtrl.RateInfo();

		// Token: 0x0400212C RID: 8492
		public global::DynamicBoneReferenceCtrl.RateInfo scale = new global::DynamicBoneReferenceCtrl.RateInfo();
	}
}
